using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace PicAFlick.App
{
    public partial class FolderItem : UserControl
    {
        public FolderItem()
        {
            InitializeComponent();
        }


        private PicAFlick.Domain.Folder _folder;

        public PicAFlick.Domain.Folder Folder
        {
            get { return _folder; }
            set { 
                _folder = value;
                if (_folder != null)
                {
                    lblFolderName.Text = _folder.Name;
                    
                }
            }
        }
        private int _nestLevel;

        public int NestLevel
        {
            get { return _nestLevel; }
            set
            {
                _nestLevel = value;
                lblFolderName.Left = (_nestLevel + 1) * 20;
                lblFolderName.Visible = false;
            }
        }

        public FolderItem(PicAFlick.Domain.Folder folder, int nestLevel)
        {
            InitializeComponent();
            this.NestLevel = nestLevel;
            this.Folder = folder;

        }


        protected override void OnPaint(PaintEventArgs e)
        {
            
            base.OnPaint(e);

            SolidBrush sb = new SolidBrush(Color.Black);
            e.Graphics.DrawString(Folder.Name, this.Font, sb, new Point((_nestLevel + 1) * 20, this.Height / 2 - this.Font.Height/2));
            for (int ic = 0; ic <= _nestLevel; ++ic)
            {
                e.Graphics.DrawLine(new Pen(sb), new Point(10 + ic * 20, 0), new Point (10 + ic * 20, this.Height));

            }
            e.Graphics.DrawLine(new Pen(sb), new Point(10 + _nestLevel * 20, Height / 2), new Point(20 + _nestLevel * 20, Height / 2));

        }


    }
}
